import requests
import json
from decimal import Decimal, getcontext
class DecimalEncoder(json.JSONEncoder):
    def default(self, o):
        if isinstance(o, Decimal):
            # 返回字符串形式的Decimal，保持精度
            return format(o, 'f')  # 或者使用其他格式化方式，如 'g' 以避免不必要的尾数零
        return super().default(o)
class THttpUtils:
    def __init__(self):
        pass

    @staticmethod
    def httpGet(url , data):
        res = ""
        try:
            resp = requests.get(url , data=data)
            if resp.status_code==200 :
                res = resp.text
        except Exception as er:
            print(er)
        return res
    @staticmethod
    def httpPost(url , dataObj):
        res = ""
        try:
            content = json.dumps(dataObj , cls=DecimalEncoder)
            resp = requests.post(url , data=content)
            res = resp.text
        except Exception as er:
            print(er)
        return res